package controllers;

import dao.*;
import play.data.FormFactory;
import play.libs.Json;
import play.libs.concurrent.HttpExecutionContext;
import play.mvc.Controller;
import play.mvc.Result;

import javax.inject.Inject;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletionStage;

import com.fasterxml.jackson.databind.JsonNode;  
import com.fasterxml.jackson.databind.node.ObjectNode;


/**
 * The controller keeps all database operations behind the repository, and uses
 * {@link play.libs.concurrent.HttpExecutionContext} to provide access to the
 * {@link play.mvc.Http.Context} methods like {@code request()} and {@code flash()}.
 */
public class EquipmentController extends Controller {

    private final FormFactory formFactory;
    private final Equipment_Repository equipment_Repository;
    private final HttpExecutionContext ec;

    @Inject
    public EquipmentController(FormFactory formFactory, Equipment_Repository equipment_Repository, HttpExecutionContext ec) {
        this.formFactory = formFactory;
        this.equipment_Repository = equipment_Repository;
        this.ec = ec;
    }
    
    public CompletionStage<Result> getEqptList() {
	    return equipment_Repository.getEqptList().thenApplyAsync(_DeptInfo -> {
	    	return ok(Json.toJson(_DeptInfo));
	    }, ec.current());
    }
}
